The present invention relates to a method for determining the piston stroke of a reciprocating piston engine having a variable stroke, for example a swashplate compressor, a pivoting plate compressor or a pivoting ring compressor, especially for air conditioning systems in motor vehicles. Such compressors are known, and it is known that the stroke of such a compressor can be determined, for example, by measuring the position of the swashplate inside the compressor. This means that these sensors in the driving space must withstand very high temperatures, pressures and the surrounding medium. Another possibility is to use electromagnetic sensors mounted on the outside of the housing to measure the stroke. However, the operation of these sensors may be impaired by a housing made of ferrous materials.